Several features
in Macromedia Flash can be used to set up a
password checking system. Using editable text
fields, variables, and the conditional If
statement, a mechanism can be created to compare a
password to a predefined string. The result is
evaluated and actions based on whether or not a
user has entered the correct password can be
executed.
The procedure outlined in this TechNote
does not provide a high level of security.
Client-side password verification is subject to
hacking and sabotage, and cannot be truly secure.
It is still possible for someone to intercept a
password or break through your scheme, and Flash
movies are no exception to this. For truly secure
password verification use server-side
authentication. Note:
The steps in this TechNote make use of the
Push Button and TextField components. These
components belong to Macromedia Flash UI
components set 2 and set 5, respectively. To
download these UI components go to the Macromedia
Exchange.
There are three main steps to building
this sample:
Collect the Data
1
|
Open a new movie. |
2 |
Navigate to Windows > Component and
drag a TextField component from the Component
window found in Flash UI
components Set 5. |
3 |
In the Property inspector name the
instance of the TextField component
myText. |
4
|
Select the Parameters tab in the Property
inspector.
For Type choose Input. Select
True for Password and False for Multiline
parameters. Leave other parameters as default
values. |
|
| Compare the Data
1
|
Drag a Push Button component from the UI components Set 2
and type a name for Label and Click
handler.
For this example, Submit is
used for Click Handler. |
|
|
2 |
Create a new layer named Actions. This is
where all your actions should reside in your
movie.
Select the first frame of the
Actions layer, open the Actions panels in Normal
mode. |
3 |
Double-click the Stop action found under
the Movie Control folder inside the Actions
folder.
This will prevent the movie to
from playing automatically when published or
exported. |
4 |
Under the Actions, choose Function inside
the User-Defined Functions folder. Type Submit in the Name text
field. |
5 |
Double-click the If action found in the Conditions/Loops
folder (Actions > Conditions/Loops
> If). |
6 |
In the Conditions field, enter
myText.text == "secret".
This compares
the value of password, which the user has
entered in the TextField component, with the
string "secret." This string is the correct
password, which can be
defined by a user.
| Send the User to
the correct location
1
|
Double-click the Goto action (Actions > Movie Control
> Goto). Select the Goto And Stop action. Enter
3 in the Frame text
field.
This will be the action that is
executed if the condition is true and will
provide confirmation that the password is
correct. |
2 |
Double-click the Else statement (Actions > Conditions/Loops
> Else).
Assign a Goto action in the following statement.
Enter 2 in the Frame input text field. Select
the option Go to and Stop.
This action
will be executed if the password entered by the
user is incorrect. |
|
|
3 |
Insert a blank keyframe in Frame
2. |
4 |
Create or drag a button from the Library
panel to the stage. |
5 |
Select the button and open the Actions
panel. |
6 |
Double-click the Goto action. This action
will take the user to the first frame of the
movie if password entered is
incorrect. |
7 |
Insert a blank keyframe in Frame 3.
|
8 |
Click the Text tool and make sure that
Static text is selected as the text type in the
Property inspector. Type a confirmation message
that tells the user they have successfully
entered the
password. |
|